<template>
    <exPubTable ref="todayTable" :cfg.sync="todaycfg" :exData="todayList" @getDataList="queryTodayInfo"  :defPageSize="100" :height="300" :show-summary="true"></exPubTable>
</template>


<script>

export default {
    data() {
        var that =this;
        return {
            totalMoney: 0,
            todayList:[],
            todaycfg:{
                showIndex: true,
                btnsWidth: 80,
                btns:[
                    {name:"删除",handle:({row,$index})=>{
                        this.todayList.splice($index,1);
                    }}
                ],
                columns: [
                    {prop:"",label:"当日成交",align:"center",
                        columns:[
                            {prop:"cjsj",label:"时间",width:70},
                            {prop:"code",label:"代码",width:70,sortable:true},
                            {prop:"name",label:"名称",width:80,sortable:true},
                            {prop:"mmsm",label:"交易类别",width:80,getColor(s){return that.getRateColor(0-s.row.cjje)}},
                            {prop:"cjsl",label:"数量",width:50,sumType:"add"},
                            {prop:"cjjg",label:"成交价格",width:80,getColor(s){return that.getRateColor(0-s.row.cjje)}},
                            {prop:"cjje",label:"成交金额",width:70,sumType:"add",formatter:this.fixed2,getColor(s){return that.getRateColor(0-s.row.cjje)}},
                            {prop:"sxf",label:"手续费",width:60,sumType:"add",formatter:this.fixed2,tips:"预估的手续费,实际手续费看交割单"},
                            {prop:"createtime",label:"创建日期",width:140,sumType:"add",sortable:true,formatter(row,col,val,idx,isSum){
                                if(isSum){
                                    return "净利 : "+this.fixed(row.cjje-row.sxf)
                                }
                                return val;
                            }},
                        ]
                    }
                ],
            },
        }
    },

    mounted() {
    },
    inject:["getQueryInfo"],

    methods: {
        reQuery(){
            if(this.$refs.todayTable) this.$refs.todayTable.reQuery();
        },
        queryTodayInfo(){
            var opername = "queryTodayInfo";
            this.registerListen(this,opername,(res)=>{
                if(res.succ){
                    this.todayList = res.data.records;
                    this.todayList.map((item,idx)=>{
                        item.createtime = this.$dayjs(item.createtime).format("YYYY-MM-DD HH:mm:ss");
                        var money =  Math.abs(item.cjje);
                        var amount = Math.abs(item.cjsl);
                        item.sxf = money*0.0002;
                        if(item.sxf<5) item.sxf = 5;
                        item.sxf += (amount/100 )*0.25; //过户费;
                        if(item.cjsl>0){
                        }else{
                            item.sxf += money*0.001;
                        }
                        item.sxf = Math.abs(item.sxf);
                    });
                }else{
                    this.$message.error("查询异常:"+res.err)
                }
            });
            var arg = this.getQueryInfo();
            delete arg.day;
            var param = {type:"commonQry",name:opername,table:"todayinfo",objInfo:arg};
            param.order = "code asc,cjsj desc";
            electron.ipcRenderer.send("doSql",param)
        },
    }
    
}
</script>

<style lang="less">

</style>
